// ====== class of 3 poles ======= //

// 10 postions of plate
final int[] PLATE_YPOS = {
  759, 727, 695, 663, 631, // plate [0, 4]
  599, 567, 535, 503, 471  // plate [5, 9]
};

class cpole {
  cpole(int x, int y, int poleNo) {
    colr = #967335;
    this.x = x;
    this.y = y;
    this.poleNo = poleNo;

    len = 230;
    thick = 25;
    halfthick = thick / 2;
    poley = 580; // y pos of this pole
    plateStack = new cplateStack();
  }

  // all rect are drwan in rectMode(RADIUS);
  void paint() {
    noStroke();
    fill(colr);
    rect(x, poley, halfthick, y - poley, 5, 5, 5, 5); // pole (verticle)
    rect(x, y, len, thick, 5, 5, 5, 5); //  base (horizontal)
    textSize(40);
    text(poleNo, x, y + 55);
  }

  void pushPlateIn(cplate plate) {
    // set x, y
    plate.x = x; // x is current pole's x
    plate.y = PLATE_YPOS[plateStack.size()]; // but y is getting higher and higher in screen

    // make it visible
    plate.visible = true;

    // push it into pole
    plateStack.push(plate);
  }

  void clearPlate() {
    plateStack.clear();
  }

  cplateStack plateStack;

  private color colr;
  protected int x;
  private int y, poley;
  private int len, thick, halfthick;
  protected int poleNo; // pole number 1, 2, 3
};


class cpole1 extends cpole {
  cpole1(int x, int y) {
    super(x, y, 1);
  }
};

class cpole2 extends cpole {
  cpole2(int x, int y) {
    super(x, y, 2);
  }
};

class cpole3 extends cpole {
  cpole3(int x, int y) {
    super(x, y, 3);
  }
};

cpole1 pole1 = new cpole1(260, 800);
cpole2 pole2 = new cpole2(800, 800);
cpole3 pole3 = new cpole3(1340, 800);

cpole[] poles = {pole1, pole2, pole3};

void draw3Poles() {
  for (cpole i : poles) {
    i.paint();
  }
}

void removeAllPlatesFrom3Pole() {
  for (cpole i : poles) {
    i.plateStack.clear();
  }
}
